package com.flexycore.iphone.view;

import com.flexycore.iphone.coregraphics.CGPoint;
import com.flexycore.iphone.coregraphics.CGRect;
import com.flexycore.iphone.uikit.UIActivityIndicatorView;
import com.flexycore.iphone.uikit.UIActivityIndicatorViewStyle;
import com.flexycore.iphone.uikit.UIColor;
import com.flexycore.iphone.uikit.UIImage;
import com.flexycore.iphone.uikit.UIImageView;
import com.flexycore.iphone.uikit.UILabel;
import com.flexycore.iphone.uikit.UITextAlignment;
import com.flexycore.iphone.uikit.UIView;

/**
 * 
 * @author matthieu nicolazo
 * 
 * Display an UIView with an ActivityIndicator animation.
 *
 */
public class PopUp extends UIView {
	/**
	 * 
	 */
	private UIActivityIndicatorView indic;
	
	/**
	 * Constructor
	 */
	public PopUp(String txt) {
		super();
		initWithFrame(CGRect.CGRectMake(0, 0, 320, 480));
		setBackgroundColor(UIColor.blackColor());
		setAlpha((float) 0.5);
		
		UIImage img = UIImage.imageNamed("popUp.tiff");
		UIImageView rect = new UIImageView();
		rect.initWithImage(img);
		rect.setCenter(new CGPoint().init(160, 220));
		
		UILabel label = new UILabel();
		label.initWithFrame(CGRect.CGRectMake(0, 170, 320, 30));
		label.setBackgroundColor(UIColor.clearColor());
		label.setText(txt);
		label.setTextColor(UIColor.whiteColor());
		label.setTextAlignment(UITextAlignment.UITextAlignmentCenter);
		
		indic = new UIActivityIndicatorView();
		indic.initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.UIActivityIndicatorViewStyleWhiteLarge);
		indic.setCenter(new CGPoint().init(160, 240));
		indic.startAnimating();
		
		addSubview(rect);
		addSubview(label);
		addSubview(indic);
	}
	
}
